package com.probiz.estore.common.model.content.base;

import java.io.Serializable;

import org.apache.commons.lang.builder.EqualsBuilder;
import org.apache.commons.lang.builder.HashCodeBuilder;
import org.apache.commons.lang.builder.ToStringBuilder;

import com.probiz.estore.core.model.BaseObject;

/**
 * Subscriber Base Java Bean, base class for the model, mapped directly to database table
 * 
 * Avoid changing this file if not necessary, will be overwritten. 
 *
 */
public class SubscriberTbl extends BaseObject implements Serializable {

    protected Integer subscriberId;
	protected String email;
	protected Integer version;
	protected com.probiz.estore.common.model.content.NewsletterGroup newsletterGroup;


	/**
	 * Default Empty Constructor for class Subscriber
	 */
	public SubscriberTbl () {
		super();
	}
	
	/**
	 * Default Key Fields Constructor for class Subscriber
	 */
	public SubscriberTbl (
		 Integer in_subscriberId
        ) {
		this.setSubscriberId(in_subscriberId);
    }

	
	public com.probiz.estore.common.model.content.NewsletterGroup getNewsletterGroup () {
		return newsletterGroup;
	}	
	
	public void setNewsletterGroup (com.probiz.estore.common.model.content.NewsletterGroup in_newsletterGroup) {
		this.newsletterGroup = in_newsletterGroup;
	}
    

	/**
	 * 	 * @return Integer
     * @hibernate.id column="subscriberId" type="java.lang.Integer" generator-class="native"
	 */
	public Integer getSubscriberId() {
		return this.subscriberId;
	}
	
	/**
	 * Set the subscriberId
	 */	
	public void setSubscriberId(Integer aValue) {
		this.subscriberId = aValue;
	}	

	/**
	 * 	 * @return String
	 * @hibernate.property column="email" type="java.lang.String" length="64" not-null="true" unique="false"
	 */
	public String getEmail() {
		return this.email;
	}
	
	/**
	 * Set the email
	 * @spring.validator type="required"
	 */	
	public void setEmail(String aValue) {
		this.email = aValue;
	}	

	/**
	 * 	 * @return Integer
	 */
	public Integer getNewsletterGroupId() {
		return this.getNewsletterGroup()==null?null:this.getNewsletterGroup().getNewsletterGroupId();
	}
	
	/**
	 * Set the newsletterGroupId
	 */	
	public void setNewsletterGroupId(Integer aValue) {
	    if (aValue==null) {
	    	newsletterGroup = null;
	    } else if (newsletterGroup == null) {
	        newsletterGroup = new com.probiz.estore.common.model.content.NewsletterGroup(aValue);
	        newsletterGroup.setVersion(Integer.valueOf(0));//set a version to cheat hibernate only
	    } else {
			newsletterGroup.setNewsletterGroupId(aValue);
	    }
	}	

	/**
	 * 	 * @return Integer
	 * @hibernate.property column="version" type="java.lang.Integer" length="10" not-null="true" unique="false"
	 */
	public Integer getVersion() {
		return this.version;
	}
	
	/**
	 * Set the version
	 * @spring.validator type="required"
	 */	
	public void setVersion(Integer aValue) {
		this.version = aValue;
	}	

	/**
	 * @see java.lang.Object#equals(Object)
	 */
	public boolean equals(Object object) {
		if (!(object instanceof SubscriberTbl)) {
			return false;
		}
		SubscriberTbl rhs = (SubscriberTbl) object;
		return new EqualsBuilder()
				.append(this.subscriberId, rhs.subscriberId)
				.append(this.email, rhs.email)
						.append(this.version, rhs.version)
				.isEquals();
	}

	/**
	 * @see java.lang.Object#hashCode()
	 */
	public int hashCode() {
		return new HashCodeBuilder(-82280557, -700257973)
				.append(this.subscriberId) 
				.append(this.email) 
						.append(this.version) 
				.toHashCode();
	}

	/**
	 * @see java.lang.Object#toString()
	 */
	public String toString() {
		return new ToStringBuilder(this)
				.append("subscriberId", this.subscriberId) 
				.append("email", this.email) 
						.append("version", this.version) 
				.toString();
	}

	/**
	 * Return the name of the first key column
	 */
	public String getFirstKeyColumnName() {
		return "subscriberId";
	}
	
	/**
	 * Return the Id (pk) of the entity, must be Integer
	 */
	public Integer getId() {
		return subscriberId;
	}

}